<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
   
   <meta name="description" content="string operations">
    
    <meta name="author" content="John S. Urban" >
    <link rel="icon" href="../favicon.png">

    <title>unquote &ndash; M_strings</title>

    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <link href="../css/pygments.css" rel="stylesheet">
    <link href="../css/font-awesome.min.css" rel="stylesheet">
    <link href="../css/local.css" rel="stylesheet">
    
    <link  href="../tipuesearch/tipuesearch.css" rel="stylesheet">
    
    

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    
    <script src="../js/jquery-2.1.3.min.js"></script>
    <script src="../js/svg-pan-zoom.min.js"></script>

  </head>

  <body>

    <!-- Fixed navbar -->
    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="../index.html">M_strings </a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
        
            <li class="dropdown hidden-xs visible-sm visible-md hidden-lg">
              <a href="#" class="dropdown-toggle"
              data-toggle="dropdown" role="button"
              aria-haspopup="true"
     aria-expanded="false">Contents <span class="caret"></span></a>
        <ul class="dropdown-menu">
          
              
            <li><a href="../lists/files.html">Source Files</a></li>
        
        
        
            <li><a href="../lists/modules.html">Modules</a></li>
        
            
                                
            <li><a href="../lists/procedures.html">Procedures</a></li>
        
               
            <li><a href="../lists/types.html">Derived Types</a></li>
        
        
            </ul>
            </li>


<li class="visible-xs hidden-sm visible-lg"><a href="../lists/files.html">Source Files</a></li>



<li class="visible-xs hidden-sm visible-lg"><a href="../lists/modules.html">Modules</a></li>



<li class="visible-xs hidden-sm visible-lg"><a href="../lists/procedures.html">Procedures</a></li>

                             
<li class="visible-xs hidden-sm visible-lg"><a href="../lists/types.html">Derived Types</a></li>


          </ul>
        
        <form action="../search.html" class="navbar-form navbar-right" role="search">
        <div class="form-group">
          <input type="text" class="form-control" placeholder="Search" name="q" id="tipue_search_input" autocomplete="off" required>
        </div>
<!--
        <button type="submit" class="btn btn-default">Submit</button>
-->
        </form>
        
        </div><!--/.nav-collapse -->
      </div>
    </nav>

    <div class="container">
    
  
  <div class="row">
    <h1>unquote
      <small>Function</small>
    
    </h1>
    
<div class="row">
  <div class="col-lg-12">
<div class="well well-sm">
  <ul class="list-inline" style="margin-bottom:0px;display:inline">
     
     
     
     
    
    
     <li><i class="fa fa-list-ol"></i>
       <a data-toggle="tooltip"
    data-placement="bottom" data-html="true"
    title=" 2.4% of total for procedures.">59 statements</a>
     </li> 
     
     
     
    <li><i class="fa fa-code"></i><a href="../src/M_strings.f90"> Source File</a></li>
     
     
  </ul>
  <ol class="breadcrumb in-well text-right">
  
    
     <li><a href='../sourcefile/m_strings.f90.html'>M_strings.f90</a></li>
    
     <li><a href='../module/m_strings.html'>M_strings</a></li>
    
  
     <li class="active">unquote</li>
  </ol>
</div>
</div>
</div>
<script>
  $(function () {
  $('[data-toggle="tooltip"]').tooltip()
  })
</script>

  </div>
  
  <div class="row">
    <div class="col-md-3 hidden-xs hidden-sm visible-md visible-lg">
    
<div id="sidebar">
  
<h3>Contents</h3>
 



<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#vars-0">Variables</a></h3></div>
  <div id="vars-0" class="panel-collapse collapse">
    <div class="list-group">
      
      <a class="list-group-item" href="../proc/unquote.html#variable-before">before</a>
      
      <a class="list-group-item" href="../proc/unquote.html#variable-current">current</a>
      
      <a class="list-group-item" href="../proc/unquote.html#variable-double_quote~2">double_quote</a>
      
      <a class="list-group-item" href="../proc/unquote.html#variable-i~18">i</a>
      
      <a class="list-group-item" href="../proc/unquote.html#variable-iesc">iesc</a>
      
      <a class="list-group-item" href="../proc/unquote.html#variable-inlen~2">inlen</a>
      
      <a class="list-group-item" href="../proc/unquote.html#variable-inside">inside</a>
      
      <a class="list-group-item" href="../proc/unquote.html#variable-iput">iput</a>
      
      <a class="list-group-item" href="../proc/unquote.html#variable-quote">quote</a>
      
      <a class="list-group-item" href="../proc/unquote.html#variable-single_quote">single_quote</a>
      
    </div>
  </div>
</div>




















<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title">Source Code</h3></div>
  <div class="list-group">
    <a class="list-group-item" href="../proc/unquote.html#src">unquote</a>
  </div>
</div>



</div>

    </div>
    
    <div class="col-md-9" id='text'>
    <h2>
public function unquote(quoted_str, esc) result(unquoted_str)
    
    
   
</h2>
    
  


    
    <h2 id="name">NAME</h2>
<div class="codehilite"><pre><span></span><code> <span class="nv">unquote</span><span class="ss">(</span><span class="mi">3</span><span class="nv">f</span><span class="ss">)</span> <span class="o">-</span> [<span class="nv">M_strings</span>:<span class="nv">QUOTES</span>] <span class="nv">remove</span> <span class="nv">quotes</span> <span class="nv">from</span> <span class="nv">string</span> <span class="nv">as</span> <span class="k">if</span>
 <span class="nv">read</span> <span class="nv">with</span> <span class="nv">list</span><span class="o">-</span><span class="nv">directed</span> <span class="nv">input</span>
 <span class="ss">(</span><span class="nv">LICENSE</span>:<span class="nv">PD</span><span class="ss">)</span>
</code></pre></div>

<h2 id="synopsis">SYNOPSIS</h2>
<p>function unquote(quoted_str,esc) result (unquoted_str)</p>
<div class="codehilite"><pre><span></span><code>character(len=*),intent(in)          :: quoted_str
character(len=1),optional,intent(in) :: esc
character(len=:),allocatable         :: unquoted_str
</code></pre></div>

<h2 id="description">DESCRIPTION</h2>
<div class="codehilite"><pre><span></span><code><span class="n">Remove</span> <span class="n">quotes</span> <span class="n">from</span> <span class="n">a</span> <span class="n">CHARACTER</span> <span class="n">variable</span> <span class="k">as</span> <span class="k">if</span> <span class="n">it</span> <span class="n">was</span> <span class="n">read</span> <span class="n">using</span>
<span class="n">list</span><span class="o">-</span><span class="n">directed</span> <span class="n">input</span><span class="o">.</span> <span class="n">This</span> <span class="k">is</span> <span class="n">particularly</span> <span class="n">useful</span> <span class="k">for</span> <span class="n">processing</span>
<span class="n">tokens</span> <span class="n">read</span> <span class="n">from</span> <span class="n">input</span> <span class="n">such</span> <span class="k">as</span> <span class="n">CSV</span> <span class="n">files</span><span class="o">.</span>

<span class="n">Fortran</span> <span class="n">can</span> <span class="n">now</span> <span class="n">read</span> <span class="n">using</span> <span class="n">list</span><span class="o">-</span><span class="n">directed</span> <span class="n">input</span> <span class="n">from</span> <span class="n">an</span> <span class="n">internal</span> <span class="n">file</span><span class="p">,</span>
<span class="n">which</span> <span class="n">should</span> <span class="n">handle</span> <span class="n">quoted</span> <span class="n">strings</span><span class="p">,</span> <span class="n">but</span> <span class="n">list</span><span class="o">-</span><span class="n">directed</span> <span class="n">input</span> <span class="n">does</span> <span class="ow">not</span>
<span class="n">support</span> <span class="n">escape</span> <span class="n">characters</span><span class="p">,</span> <span class="n">which</span> <span class="n">UNQUOTE</span><span class="p">(</span><span class="mi">3</span><span class="n">f</span><span class="p">)</span> <span class="n">does</span><span class="o">.</span>
</code></pre></div>

<h2 id="options">OPTIONS</h2>
<div class="codehilite"><pre><span></span><code><span class="n">quoted_str</span>  <span class="k">input</span> <span class="k">string</span> <span class="n">to</span> <span class="n">remove</span> <span class="n">quotes</span> <span class="n">from</span><span class="p">,</span> <span class="n">using</span> <span class="n">the</span> <span class="n">rules</span> <span class="n">of</span>
            <span class="n">list</span><span class="o">-</span><span class="n">directed</span> <span class="k">input</span> <span class="p">(</span><span class="n">two</span> <span class="n">adjacent</span> <span class="n">quotes</span> <span class="n">inside</span> <span class="n">a</span> <span class="n">quoted</span>
            <span class="n">region</span> <span class="n">are</span> <span class="n">replaced</span> <span class="n">by</span> <span class="n">a</span> <span class="n">single</span> <span class="n">quote</span><span class="p">,</span> <span class="n">a</span> <span class="n">single</span> <span class="n">quote</span> <span class="k">or</span>
            <span class="n">double</span> <span class="n">quote</span> <span class="n">is</span> <span class="n">selected</span> <span class="n">as</span> <span class="n">the</span> <span class="n">delimiter</span> <span class="n">based</span> <span class="n">on</span> <span class="n">which</span>
            <span class="n">is</span> <span class="n">encountered</span> <span class="n">first</span> <span class="n">going</span> <span class="n">from</span> <span class="n">left</span> <span class="n">to</span> <span class="n">right</span><span class="p">,</span> <span class="p">...)</span>
<span class="n">esc</span>         <span class="n">optional</span> <span class="n">character</span> <span class="n">used</span> <span class="n">to</span> <span class="n">protect</span> <span class="n">the</span> <span class="n">next</span> <span class="n">quote</span>
            <span class="n">character</span> <span class="n">from</span> <span class="n">being</span> <span class="n">processed</span> <span class="n">as</span> <span class="n">a</span> <span class="n">quote</span><span class="p">,</span> <span class="n">but</span> <span class="n">simply</span> <span class="n">as</span>
            <span class="n">a</span> <span class="n">plain</span> <span class="n">character</span><span class="p">.</span>
</code></pre></div>

<h2 id="result">RESULT</h2>
<div class="codehilite"><pre><span></span><code>unquoted_str  The output string, which is based on removing quotes
              from quoted_str.
</code></pre></div>

<h2 id="example">EXAMPLE</h2>
<p>Sample program:</p>
<div class="codehilite"><pre><span></span><code><span class="nv">program</span> <span class="nv">demo_unquote</span>
   <span class="nv">use</span> <span class="nv">M_strings</span>, <span class="nv">only</span> : <span class="nv">unquote</span>
   <span class="nv">implicit</span> <span class="nv">none</span>
   <span class="nv">character</span><span class="ss">(</span><span class="nv">len</span><span class="o">=</span><span class="mi">128</span><span class="ss">)</span>           :: <span class="nv">quoted_str</span>
   <span class="nv">character</span><span class="ss">(</span><span class="nv">len</span><span class="o">=</span>:<span class="ss">)</span>,<span class="nv">allocatable</span> :: <span class="nv">unquoted_str</span>
   <span class="nv">character</span><span class="ss">(</span><span class="nv">len</span><span class="o">=</span><span class="mi">1</span><span class="ss">)</span>,<span class="nv">parameter</span>   :: <span class="nv">esc</span><span class="o">=</span><span class="s1">&#39;</span><span class="s">\</span><span class="s1">&#39;</span>
   <span class="nv">character</span><span class="ss">(</span><span class="nv">len</span><span class="o">=</span><span class="mi">1024</span><span class="ss">)</span>          :: <span class="nv">msg</span>
   <span class="nv">integer</span>                      :: <span class="nv">ios</span>
   <span class="nv">character</span><span class="ss">(</span><span class="nv">len</span><span class="o">=</span><span class="mi">1024</span><span class="ss">)</span>          :: <span class="nv">dummy</span>
   <span class="k">do</span>
      <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="s1">&#39;</span><span class="s">(a)</span><span class="s1">&#39;</span>,<span class="nv">advance</span><span class="o">=</span><span class="s1">&#39;</span><span class="s">no</span><span class="s1">&#39;</span><span class="ss">)</span><span class="s1">&#39;</span><span class="s">Enter test string:</span><span class="s1">&#39;</span>
      <span class="nv">read</span><span class="ss">(</span><span class="o">*</span>,<span class="s1">&#39;</span><span class="s">(a)</span><span class="s1">&#39;</span>,<span class="nv">iostat</span><span class="o">=</span><span class="nv">ios</span>,<span class="nv">iomsg</span><span class="o">=</span><span class="nv">msg</span><span class="ss">)</span><span class="nv">quoted_str</span>
      <span class="k">if</span><span class="ss">(</span><span class="nv">ios</span>.<span class="nv">ne</span>.<span class="mi">0</span><span class="ss">)</span><span class="k">then</span>
         <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="o">*</span><span class="ss">)</span><span class="nv">trim</span><span class="ss">(</span><span class="nv">msg</span><span class="ss">)</span>
         <span class="k">exit</span>
      <span class="k">endif</span>

      <span class="o">!</span> <span class="nv">the</span> <span class="nv">original</span> <span class="nv">string</span>
      <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="s1">&#39;</span><span class="s">(a)</span><span class="s1">&#39;</span><span class="ss">)</span><span class="s1">&#39;</span><span class="s">QUOTED       [</span><span class="s1">&#39;</span><span class="o">//</span><span class="nv">trim</span><span class="ss">(</span><span class="nv">quoted_str</span><span class="ss">)</span><span class="o">//</span><span class="s1">&#39;</span><span class="s">]</span><span class="s1">&#39;</span>

      <span class="o">!</span> <span class="nv">the</span> <span class="nv">string</span> <span class="nv">processed</span> <span class="nv">by</span> <span class="nv">unquote</span><span class="ss">(</span><span class="mi">3</span><span class="nv">f</span><span class="ss">)</span>
      <span class="nv">unquoted_str</span><span class="o">=</span><span class="nv">unquote</span><span class="ss">(</span><span class="nv">trim</span><span class="ss">(</span><span class="nv">quoted_str</span><span class="ss">)</span>,<span class="nv">esc</span><span class="ss">)</span>
      <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="s1">&#39;</span><span class="s">(a)</span><span class="s1">&#39;</span><span class="ss">)</span><span class="s1">&#39;</span><span class="s">UNQUOTED     [</span><span class="s1">&#39;</span><span class="o">//</span><span class="nv">unquoted_str</span><span class="o">//</span><span class="s1">&#39;</span><span class="s">]</span><span class="s1">&#39;</span>

      <span class="o">!</span> <span class="nv">read</span> <span class="nv">the</span> <span class="nv">string</span> <span class="nv">list</span><span class="o">-</span><span class="nv">directed</span> <span class="nv">to</span> <span class="nv">compare</span> <span class="nv">the</span> <span class="nv">results</span>
      <span class="nv">read</span><span class="ss">(</span><span class="nv">quoted_str</span>,<span class="o">*</span>,<span class="nv">iostat</span><span class="o">=</span><span class="nv">ios</span>,<span class="nv">iomsg</span><span class="o">=</span><span class="nv">msg</span><span class="ss">)</span><span class="nv">dummy</span>
      <span class="k">if</span><span class="ss">(</span><span class="nv">ios</span>.<span class="nv">ne</span>.<span class="mi">0</span><span class="ss">)</span><span class="k">then</span>
         <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="o">*</span><span class="ss">)</span><span class="nv">trim</span><span class="ss">(</span><span class="nv">msg</span><span class="ss">)</span>
      <span class="k">else</span>
         <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="s1">&#39;</span><span class="s">(a)</span><span class="s1">&#39;</span><span class="ss">)</span><span class="s1">&#39;</span><span class="s">LIST DIRECTED[</span><span class="s1">&#39;</span><span class="o">//</span><span class="nv">trim</span><span class="ss">(</span><span class="nv">dummy</span><span class="ss">)</span><span class="o">//</span><span class="s1">&#39;</span><span class="s">]</span><span class="s1">&#39;</span>
      <span class="k">endif</span>
   <span class="nv">enddo</span>
<span class="k">end</span> <span class="nv">program</span> <span class="nv">demo_unquote</span>
</code></pre></div>

<h2 id="author">AUTHOR</h2>
<div class="codehilite"><pre><span></span><code>John S. Urban
</code></pre></div>

<h2 id="license">LICENSE</h2>
<div class="codehilite"><pre><span></span><code>Public Domain
</code></pre></div>
    

    <h3>Arguments</h3>
    
      
<table class="table table-striped varlist">
<thead><tr><th>Type</th>
<th>Intent</th><th>Optional</th>
<th>Attributes</th><th></th><th>Name</th><th></th></thead>



<tbody>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-quoted_str~2"></span>character(len=*),</td>
  <td>intent(in)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>quoted_str</strong></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-esc~2"></span>character(len=1),</td>
  <td>intent(in),</td>
  <td>optional</td>
  
  <td></td><td>::</td>
  <td><strong>esc</strong></td><td></td>
  
</tr>

</tbody>
</table>

    
    
    
    
    
    
    
   <h3>Return Value <small><span class="anchor" id="variable-unquoted_str"></span>character(len=:),
  allocatable</small></h3>
    
    
    
    
     
    <br>

    <section class="visible-xs visible-sm hidden-md">
      
<h3>Contents</h3>
 



<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#vars-1">Variables</a></h3></div>
  <div id="vars-1" class="panel-collapse collapse">
    <div class="list-group">
      
      <a class="list-group-item" href="../proc/unquote.html#variable-before">before</a>
      
      <a class="list-group-item" href="../proc/unquote.html#variable-current">current</a>
      
      <a class="list-group-item" href="../proc/unquote.html#variable-double_quote~2">double_quote</a>
      
      <a class="list-group-item" href="../proc/unquote.html#variable-i~18">i</a>
      
      <a class="list-group-item" href="../proc/unquote.html#variable-iesc">iesc</a>
      
      <a class="list-group-item" href="../proc/unquote.html#variable-inlen~2">inlen</a>
      
      <a class="list-group-item" href="../proc/unquote.html#variable-inside">inside</a>
      
      <a class="list-group-item" href="../proc/unquote.html#variable-iput">iput</a>
      
      <a class="list-group-item" href="../proc/unquote.html#variable-quote">quote</a>
      
      <a class="list-group-item" href="../proc/unquote.html#variable-single_quote">single_quote</a>
      
    </div>
  </div>
</div>




















<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title">Source Code</h3></div>
  <div class="list-group">
    <a class="list-group-item" href="../proc/unquote.html#src">unquote</a>
  </div>
</div>



    </section>
    <br class="visible-xs visible-sm hidden-md">

    

    
    <section>    
      <h2>Variables</h2>
    
<table class="table table-striped varlist">
<thead><tr><th>Type</th><th>Visibility</th>

<th>Attributes</th><th></th><th>Name</th><th></th><th>Initial</th><th></th></thead>



<tbody>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-before"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>before</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-current"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>current</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-double_quote~2"></span>character(len=1),</td>
  
  <td>public,</td>
  <td>parameter</td><td>::</td>
  <td><strong>double_quote</strong></td><td> =</td><td>'"'</td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-i~18"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>i</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-iesc"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>iesc</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-inlen~2"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>inlen</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-inside"></span>logical,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>inside</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-iput"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>iput</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-quote"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>quote</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-single_quote"></span>character(len=1),</td>
  
  <td>public,</td>
  <td>parameter</td><td>::</td>
  <td><strong>single_quote</strong></td><td> =</td><td>"'"</td><td></td>
  
</tr>

</tbody>
</table>

    </section>
    <br>
    
    
    
    
    

    
    
    
    
    


    
    
    
    <section>
    <h2><span class="anchor" id="src"></span>Source Code</h2>
    <div class="highlight"><pre><span></span><span class="k">function </span><span class="n">unquote</span><span class="p">(</span><span class="n">quoted_str</span><span class="p">,</span><span class="n">esc</span><span class="p">)</span> <span class="k">result</span> <span class="p">(</span><span class="n">unquoted_str</span><span class="p">)</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=*</span><span class="p">),</span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span>          <span class="kd">::</span> <span class="n">quoted_str</span>              <span class="c">! the string to be unquoted</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="mi">1</span><span class="p">),</span><span class="k">optional</span><span class="p">,</span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span> <span class="kd">::</span> <span class="n">esc</span>                     <span class="c">! escape character</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="p">:),</span><span class="k">allocatable</span>         <span class="kd">::</span> <span class="n">unquoted_str</span>
<span class="kt">integer</span>                              <span class="kd">::</span> <span class="n">inlen</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="mi">1</span><span class="p">),</span><span class="k">parameter</span>           <span class="kd">::</span> <span class="n">single_quote</span> <span class="o">=</span> <span class="s2">&quot;&#39;&quot;</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="mi">1</span><span class="p">),</span><span class="k">parameter</span>           <span class="kd">::</span> <span class="n">double_quote</span> <span class="o">=</span> <span class="s1">&#39;&quot;&#39;</span>
<span class="kt">integer</span>                              <span class="kd">::</span> <span class="n">quote</span>                   <span class="c">! whichever quote is to be used</span>
<span class="kt">integer</span>                              <span class="kd">::</span> <span class="n">before</span>
<span class="kt">integer</span>                              <span class="kd">::</span> <span class="n">current</span>
<span class="kt">integer</span>                              <span class="kd">::</span> <span class="n">iesc</span>
<span class="kt">integer</span>                              <span class="kd">::</span> <span class="n">iput</span>
<span class="kt">integer</span>                              <span class="kd">::</span> <span class="n">i</span>
<span class="kt">logical</span>                              <span class="kd">::</span> <span class="n">inside</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>
   <span class="k">if</span><span class="p">(</span><span class="nb">present</span><span class="p">(</span><span class="n">esc</span><span class="p">))</span><span class="k">then</span>                           <span class="c">! select escape character as specified character or special value meaning not set</span>
      <span class="n">iesc</span><span class="o">=</span><span class="nb">iachar</span><span class="p">(</span><span class="n">esc</span><span class="p">)</span>                            <span class="c">! allow for an escape character</span>
   <span class="k">else</span>
<span class="k">      </span><span class="n">iesc</span><span class="o">=-</span><span class="mi">1</span>                                     <span class="c">! set to value that matches no character</span>
   <span class="k">endif</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>
   <span class="n">inlen</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">quoted_str</span><span class="p">)</span>                          <span class="c">! find length of input string</span>
   <span class="k">allocate</span><span class="p">(</span><span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="n">inlen</span><span class="p">)</span> <span class="kd">::</span> <span class="n">unquoted_str</span><span class="p">)</span> <span class="c">! initially make output string length of input string</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>
   <span class="k">if</span><span class="p">(</span><span class="n">inlen</span><span class="p">.</span><span class="n">ge</span><span class="p">.</span><span class="mi">1</span><span class="p">)</span><span class="k">then</span>                             <span class="c">! double_quote is the default quote unless the first character is single_quote</span>
      <span class="k">if</span><span class="p">(</span><span class="n">quoted_str</span><span class="p">(</span><span class="mi">1</span><span class="p">:</span><span class="mi">1</span><span class="p">).</span><span class="n">eq</span><span class="p">.</span><span class="n">single_quote</span><span class="p">)</span><span class="k">then</span>
<span class="k">         </span><span class="n">quote</span><span class="o">=</span><span class="nb">iachar</span><span class="p">(</span><span class="n">single_quote</span><span class="p">)</span>
      <span class="k">else</span>
<span class="k">         </span><span class="n">quote</span><span class="o">=</span><span class="nb">iachar</span><span class="p">(</span><span class="n">double_quote</span><span class="p">)</span>
      <span class="k">endif</span>
<span class="k">   else</span>
<span class="k">      </span><span class="n">quote</span><span class="o">=</span><span class="nb">iachar</span><span class="p">(</span><span class="n">double_quote</span><span class="p">)</span>
   <span class="k">endif</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>
   <span class="n">before</span><span class="o">=-</span><span class="mi">2</span>                                      <span class="c">! initially set previous character to impossible value</span>
   <span class="n">unquoted_str</span><span class="p">(:)</span><span class="o">=</span><span class="s1">&#39;&#39;</span>                             <span class="c">! initialize output string to null string</span>
   <span class="n">iput</span><span class="o">=</span><span class="mi">1</span>
   <span class="n">inside</span><span class="o">=</span><span class="p">.</span><span class="n">false</span><span class="p">.</span>
   <span class="n">STEPTHROUGH</span><span class="p">:</span> <span class="k">do </span><span class="n">i</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span><span class="n">inlen</span>
      <span class="n">current</span><span class="o">=</span><span class="nb">iachar</span><span class="p">(</span><span class="n">quoted_str</span><span class="p">(</span><span class="n">i</span><span class="p">:</span><span class="n">i</span><span class="p">))</span>
      <span class="k">if</span><span class="p">(</span><span class="n">before</span><span class="p">.</span><span class="n">eq</span><span class="p">.</span><span class="n">iesc</span><span class="p">)</span><span class="k">then</span>                      <span class="c">! if previous character was escape use current character unconditionally</span>
           <span class="n">iput</span><span class="o">=</span><span class="n">iput</span><span class="o">-</span><span class="mi">1</span>                            <span class="c">! backup</span>
           <span class="n">unquoted_str</span><span class="p">(</span><span class="n">iput</span><span class="p">:</span><span class="n">iput</span><span class="p">)</span><span class="o">=</span><span class="nb">char</span><span class="p">(</span><span class="n">current</span><span class="p">)</span>
           <span class="n">iput</span><span class="o">=</span><span class="n">iput</span><span class="o">+</span><span class="mi">1</span>
           <span class="n">before</span><span class="o">=-</span><span class="mi">2</span>                              <span class="c">! this could be second esc or quote</span>
      <span class="n">elseif</span><span class="p">(</span><span class="n">current</span><span class="p">.</span><span class="n">eq</span><span class="p">.</span><span class="n">quote</span><span class="p">)</span><span class="k">then</span>                <span class="c">! if current is a quote it depends on whether previous character was a quote</span>
         <span class="k">if</span><span class="p">(</span><span class="n">before</span><span class="p">.</span><span class="n">eq</span><span class="p">.</span><span class="n">quote</span><span class="p">)</span><span class="k">then</span>
<span class="k">           </span><span class="n">unquoted_str</span><span class="p">(</span><span class="n">iput</span><span class="p">:</span><span class="n">iput</span><span class="p">)</span><span class="o">=</span><span class="nb">char</span><span class="p">(</span><span class="n">quote</span><span class="p">)</span>    <span class="c">! this is second quote so retain it</span>
           <span class="n">iput</span><span class="o">=</span><span class="n">iput</span><span class="o">+</span><span class="mi">1</span>
           <span class="n">before</span><span class="o">=-</span><span class="mi">2</span>
         <span class="n">elseif</span><span class="p">(.</span><span class="nb">not</span><span class="p">.</span><span class="n">inside</span><span class="p">.</span><span class="nb">and</span><span class="p">.</span><span class="n">before</span><span class="p">.</span><span class="n">ne</span><span class="p">.</span><span class="n">iesc</span><span class="p">)</span><span class="k">then</span>
<span class="k">            </span><span class="n">inside</span><span class="o">=</span><span class="p">.</span><span class="n">true</span><span class="p">.</span>
         <span class="k">else</span>                                     <span class="c">! this is first quote so ignore it except remember it in case next is a quote</span>
            <span class="n">before</span><span class="o">=</span><span class="n">current</span>
         <span class="k">endif</span>
<span class="k">      else</span>
<span class="k">         </span><span class="n">unquoted_str</span><span class="p">(</span><span class="n">iput</span><span class="p">:</span><span class="n">iput</span><span class="p">)</span><span class="o">=</span><span class="nb">char</span><span class="p">(</span><span class="n">current</span><span class="p">)</span>
         <span class="n">iput</span><span class="o">=</span><span class="n">iput</span><span class="o">+</span><span class="mi">1</span>
         <span class="n">before</span><span class="o">=</span><span class="n">current</span>
      <span class="k">endif</span>
<span class="k">   enddo </span><span class="n">STEPTHROUGH</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>
   <span class="n">unquoted_str</span><span class="o">=</span><span class="n">unquoted_str</span><span class="p">(:</span><span class="n">iput</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>
<span class="k">end function </span><span class="n">unquote</span>
</pre></div>

    </section>
    <br>
    
    
    </div>
  </div>


    <hr>    
    </div> <!-- /container -->
    <footer>
      <div class="container">
      <div class="row">
        <div class="col-xs-6 col-md-4"><p>&copy; 2022 
                                          </p></div>
        <div class="col-xs-6 col-md-4 col-md-push-4">
          <p class="text-right">
            Documentation generated by 
            <a href="https://github.com/cmacmackin/ford">FORD</a>
             on 2022-01-16 22:32  
          </p>
        </div>
        <div class="col-xs-12 col-md-4 col-md-pull-4"><p class="text-center"> M_strings was developed by John S. Urban</p></div>
      </div>
      <br>
      </div> <!-- /container -->    
    </footer>

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
<!--
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
-->
    <script src="../js/bootstrap.min.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="../js/ie10-viewport-bug-workaround.js"></script>

    <!-- MathJax JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        TeX: { extensions: ['AMSmath.js','AMSsymbols.js','noErrors.js','noUndefined.js'], equationNumbers: { autoNumber: 'AMS' } },
        jax: ['input/TeX','input/MathML','output/HTML-CSS'],
        extensions: ['tex2jax.js','mml2jax.js','MathMenu.js','MathZoom.js']
      });
    </script>
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    
    <script src="../tipuesearch/tipuesearch_content.js"></script>
    <script src="../tipuesearch/tipuesearch_set.js"></script>
    <script src="../tipuesearch/tipuesearch.js"></script>
    
    
  </body>
</html>